package org.webdriver.patatiumwebui.action;

import org.openqa.selenium.WebDriver;
import org.webdriver.patatiumwebui.pageObject.BleumcLoginPage;
import org.webdriver.patatiumwebui.utils.ElementAction;
import org.webdriver.patatiumwebui.utils.TestBaseCase;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

/**
 * Created by zhengshuheng on 2016/8/29 0029.
 */
public class BlueMCLoginAction extends TestBaseCase{
    public BlueMCLoginAction(String Url, String UserName, String PassWord) throws IOException
    {
        WebDriver.Options manage = driver.manage();
        WebDriver.Timeouts timeouts = manage.timeouts();


        //此driver变量继承自TestBase变量
        BleumcLoginPage loginPage=new BleumcLoginPage();
        loginPage.open(Url);

        timeouts.pageLoadTimeout(40, TimeUnit.SECONDS);

        driver=driver.switchTo().frame(0);

        ElementAction action=new ElementAction();
        action.sleep(1);
        action.clear(loginPage.密码输入框());
        action.type(loginPage.用户名输入框(),UserName);
        action.clear(loginPage.密码输入框());
        action.type(loginPage.密码输入框(),PassWord);
        action.click(loginPage.登录按钮());
    }
}
